﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using Data;

namespace Business
{

    public class Comentario
    {
        private int eventID;
        private int userID;
        private int commentID;
        private String username;
        private String comment;
        private int status;
        private DateTime data;

        private DataComentario dataLayer;

        // Construtores

        public Comentario()
        {
            this.commentID = -1;
            this.eventID = -1;
            this.userID = -1;
            this.username = "";
            this.comment = "";
            this.status = -1;
            this.data = new DateTime();
            this.dataLayer = new DataComentario();
        }

        public Comentario(int eventID, int userID, String username, String comment, DateTime data)
        {
            this.eventID = eventID;
            this.userID = userID;
            this.commentID = -1;
            this.username = username;
            this.comment = comment;
            this.data = data;
            this.status = -1;
            this.dataLayer = new DataComentario();
        }



        public Comentario(Comentario c)
        {
            this.commentID = c.getComentarioID();
            this.eventID = c.getComentarioEventoID();
            this.userID = c.getComentarioUtilizadorID();
            this.username = c.getComentarioUsername();
            this.comment = c.getComentarioText();
            this.status = c.getComentarioStatus();
            this.data = c.getComentarioData();

            this.dataLayer = new DataComentario();
        }


        // Get's
        public int getComentarioEventoID() { return this.eventID; }
        public int getComentarioUtilizadorID() { return this.userID; }
        public String getComentarioUsername() { return this.username; }
        public String getComentarioText() { return this.comment; }
        public int getComentarioStatus() { return this.status; }
        public DateTime getComentarioData() { return this.data; }
        public int getComentarioID() { return this.commentID; }

        // Set's
        public void setComentarioEventoID(int eventID) { this.eventID = eventID; }
        public void setComentarioUserID(int userID) { this.userID = userID; }
        public void setComentarioUsername(String username) { this.username = username; }
        public void setComentarioText(String comment) { this.comment = comment; }
        public void setComentarioStatus(int status) { this.status = status; }
        public void setComentarioData(DateTime data) { this.data = data; }
        public void setComentarioID(int id) { this.commentID = id; }

        // Métodos da camada de Negócio

        public String insertComentario()
        {
            String str = this.dataLayer.insertComentario(this);
            //this.commentID = this.dataLayer.insertComentario(this);
            this.status = 1;
            //return this.commentID;
            return str;
        }

        public bool setEstadoComentario(int novoEstado)
        {
            return this.dataLayer.setEstadoComentario(this, novoEstado);
        }

        public Comentario getComentarioByID(int commentID)
        {
            return this.dataLayer.getComentarioByID(commentID);
        }
    }

}